/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  							 script_branch_action.cpp

	$Header: /heroes4/script_branch_action.cpp $

	$NoKeywords: $

 ************************************************************************/

#include "precompiled.h"
#include "script_branch_action.h"
#include "assert.h"

// --------------------------------------------------------------------------
// t_script_branch_action members
// --------------------------------------------------------------------------

bool t_script_branch_action::read_from_map(
	std::streambuf &	stream,
	int					format_version )
{
	m_true_subaction_ptr = t_subaction::reconstruct_from_map( stream, format_version );
	if ( m_true_subaction_ptr.get() == 0 )
		return false;

	m_false_subaction_ptr = t_subaction::reconstruct_from_map( stream, format_version );
	return m_false_subaction_ptr.get() != 0;
}

bool t_script_branch_action::read( std::streambuf& stream, int version )
{
	m_true_subaction_ptr = t_subaction::reconstruct( stream, version );
	if ( m_true_subaction_ptr.get() == 0 )
		return false;

	m_false_subaction_ptr = t_subaction::reconstruct( stream, version );
	return m_false_subaction_ptr.get() != 0;
}

bool t_script_branch_action::write( std::streambuf& stream ) const
{
	if ( !t_abstract_script_action::write( stream ) )
		return false;

	if ( !m_true_subaction_ptr->write( stream ) )
		return false;

	return m_false_subaction_ptr->write( stream );
}

